﻿using System;
using System.Collections.Generic;
using System.Text;
using NetworkLib.Utilities;

namespace PokemonBattle.BattleNetwork
{
    public enum BattleMode : int
    {
        /// <summary>
        /// 1 v 1
        /// </summary>
        Single = 1234456403,

        /// <summary>
        /// 2 v 2
        /// </summary>
        Double = 1235498031,

        /// <summary>
        /// 
        /// </summary>
        Double_4P = 1451510949,

        /// <summary>
        /// None
        /// </summary>
        WrongInput = -1
    }

    public static class BattleModeHelper
    {
        public static BattleMode ReadFromByteArray(ByteArray byteArray)
        {
            int val = byteArray.ReadInt();
            return Parse(val);
        }

        public static BattleMode Parse(int val)
        {
            foreach (int value in Enum.GetValues(typeof(BattleMode)))
            {
                if (value == val) return (BattleMode)value;
            }
            return BattleMode.WrongInput;
        }

        public static void WriteToByteArray(ByteArray byteArray, BattleMode value)
        {
            byteArray.WriteInt((int)value);
        }
    }
}
